<template>
  <view class="us-container">
    <navbar title="关于我们" show-logo/>
    <view class="body">
      <rich-text :nodes="content" preview class="rich" @itemclick="clickImage"/>
      <view class="phone mt-30" v-if="phone.length">
        <text class="iconfont icon-tel"/>
        <text class="phone-text" v-for="(item, index) in phone" :key="index" @click="callPhone(item.phone)">
          {{item.name}}{{item.phone}}
          <text v-if="index < phone.length - 1">、</text>
        </text>
      </view>
    </view>
    <u-safe-bottom/>
  </view>
</template>

<script>
import {getCompanyInfo} from "@/api/my";
import utils from "@/common/utils";

export default {
  data() {
    return {
      phone: [],
      content: ''
    };
  },
  methods: {
    getInfo() {
      getCompanyInfo().then(res => {
        this.phone = (res.phoneList || [])
        this.content = utils.formatRichText(res.description)
      })
    },
    clickImage(e) {
      const node = e.detail.node
      if (node.name == 'img') {
        uni.previewImage({
          urls: [node.attrs.src]
        })
      }
    },
    callPhone(phone) {
      uni.makePhoneCall({
        phoneNumber: phone
      })
    }
  },
  onLoad() {
    this.getInfo();
  },
}
</script>

<style lang="scss">
.body {
  padding: 30rpx 40rpx;
  color: #fff;
  .phone {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 40rpx;
    .iconfont {
      margin-right: 20rpx;
      font-size: 32rpx;
    }
    .phone-text {
      margin-right: 10rpx;
    }
  }
  .rich {
    line-height: 1.5;
    img {
      max-width: 100%;
    }
  }
}
</style>
